<div>
    <!--部门查询页面-->
    <div class="ui top fluid attach container segment">
        <div class="ui blue top attached label">报表统计</div>
        <div style="height: 1em;">
            注意：目前仅统计产生数据的部门情况！
        </div>
        <div class="ui fluid container segment" id="statistic-depart-echarts" style="height: 39.8em;">

        </div>
    </div>
</div>

<script>

    departChart = echarts.init(document.getElementById('statistic-depart-echarts'));
    depart = [];
    departParam = [];
    $.ajax({
        url: "queryStatisticByDepart",
        type: 'post',
        data: "",
        async: false,
        beforeSend: (request) => {
            if (constant.csrfToken && constant.csrfHeader) {
                request.setRequestHeader(constant.csrfHeader, constant.csrfToken);
            }
        },
        success: (data) => {
            if ('0' === data.statusCode) {
                let res = data.resultList;
                for (let i = 0; i < res.length; i++) {
                    depart[i] = res[i].name;
                    departParam[i] = res[i].num;
                }
                closeWaitPromptBox();
            } else if ('-1' === data.statusCode) {
                closeWaitPromptBox();
                showErrorPromptBox("", 2);
            }
        },
        error: () => {
            closeWaitPromptBox();
            showErrorPromptBox("系统繁忙，请稍后访问！", 2);
        }
    });
    optionDepart = {
        tooltip: {
            trigger: 'axis',
            axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
            }
        },
        grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        xAxis: [
            {
                type: 'category',
                data: depart,
                axisTick: {
                    alignWithLabel: true
                }
            }
        ],
        yAxis: [
            {
                type: 'value'
            }
        ],
        series: [
            {
                name: depart,
                type: 'bar',
                barWidth: 32,
                itemStyle : {
                    normal : {
                        label: {
                            show: true,
                            position: 'top',
                            textStyle: {
                                color: 'blue'
                            }
                        }
                    },
                },
                data: departParam
            }
        ]
    };

    optionDepart && departChart.setOption(optionDepart);

</script>